package main

import (
	"bufio"
	"fmt"
	"strconv"
	"strings"
)

//func main() {
//	var n = []int{1, 39, 2, 9, 7, 54, 11}
//	var isDone = false
//	for !isDone {
//		isDone = true
//		var i = 0
//		for i < len(n) - 1 {
//			if n[i] > n[i + 1] {
//				var temp = n[i]
//				n[i] = n[i + 1]
//				n[i + 1] = temp
//				isDone = false
//			}
//			i++
//		}
//	}
//	fmt.Println(n)
//}
func main() {
	// An artificial input source.
	const input = "1234 5678 1234567901234567890"
	scanner := bufio.NewScanner(strings.NewReader(input))
	// Create a custom split function by wrapping the existing ScanWords function.
	split := func(data []byte, atEOF bool) (advance int, token []byte, err error) {
		advance, token, err = bufio.ScanWords(data, atEOF)
		if err == nil && token != nil {
			_, err = strconv.ParseInt(string(token), 10, 32)
		}
		return
	}
	// Set the split function for the scanning operation.
	scanner.Split(split)
	// Validate the input
	for scanner.Scan() {
		fmt.Printf("%s\n", scanner.Text())
	}

	if err := scanner.Err(); err != nil {
		fmt.Printf("Invalid input: %s", err)
	}
}
